<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>demo2</title>
  </head>
  <body></body>
  <script src="../dist/axios.js"></script>

  <script>
    axios.interceptors.request.use(
      config => {
        console.log('请求拦截器调用，设置 Authorization');
        config.headers['Authorization'] = 'Bearer xxxxx';
        return config;
      },
      error => {
        console.log(error);
        return Promise.reject();
      }
    );

    axios.interceptors.response.use(
      response => {
        console.log('响应拦截器调用，处理响应体');
        return response;
      },
      error => {
        console.log(error);
        return Promise.reject();
      }
    );

    axios.get('http://localhost:3000/user?ID=12345').then(res => {
      console.log(res);
    });
  </script>
</html>
